import org.gruposp2p.proyectokarma.util.StringUtils;

class KarmaFilters {
	
	def filters = {
		all(controller:'*', action:'*') {
			before = {
	            log.debug "###########################<${params.controller}>###################################"
	            log.debug "Method: " + request.method + " -Params: " + params 
	            log.debug "Request: " + request.getRequestURI()  + " - RemoteAddr: " + request.getRemoteAddr()
				log.debug "User agent: " + request.getHeader("User-Agent")
	            log.debug "-----------------------------------------------------------------------------------"
				if (request.method == "GET") {
					if(!params.int("max")) params.max = 20
					if(!params.int("offset")) params.offset = 0
					if(!params.sort) params.sort = "dateCreated"
					if(!params.order) params.order = "desc"
					response.setHeader("Cache-Control", "no-store")
					params.ids = StringUtils.checkIds(params.id)
				}
			}
		}

	}

}
